package grafico;

import main.Contexto;

public class GeraHTML 
{
	static private GeraHTML instancia = null;
	
	private Contexto contexto;
	
	private GeraHTML()
	{
		contexto = Contexto.instancia();
	}

	static public GeraHTML instancia()
	{
		if ( instancia == null )
			instancia = new GeraHTML();
		
		return instancia;
	}
	
	public String geraDiv( String str )
	{
		return "<div style='background-color: #" + contexto.getCorFundo() + "; " +
						   "color: #" + contexto.getCorTexto() + "; " +
						   "font-size: " + contexto.getTamFonte() + "pt;'>" + 
						   str + "</div>";
		
	}

	public String geraP( String str )
	{
		return "<p style='background-color: #" + contexto.getCorFundo() + "; " +
						 "color: #" + contexto.getCorTexto() + "; " +
						 "font-size: " + contexto.getTamFonte() + "pt; " +
						 "text-align: justify; '>" + str + "</p>";
	}

	public String geraHn( int nivel, String str )
	{
		int tam = contexto.getTamFonte();;
		
		switch ( nivel )
		{
		case 1: tam += 6; break;
		case 2: tam += 4; break;
		case 3: tam += 2; break;
		case 4:           break;
		case 5: tam -= 2; break;
		case 6: tam -= 4; break;
		}
		
		return "<h" + nivel + 
				 " style='background-color: #" + contexto.getCorFundo() + "; " +
				 "color: #" + contexto.getCorTexto() + "; " +
				 "font-size: " + tam + "pt; " +
				 "text-align: justify; '>" + str + "</h" + nivel + ">";
	}
}
